import xlrd
from ChatbotWithRetrieval import ChatbotWithRetrieval

llm = ChatbotWithRetrieval("my_vectors.faiss")

# # 打开文件
# data = xlrd.open_workbook(r'C:\Users\Yang.Shen9\Documents\yy_knowledge.xlsx')
#
# vlanSheet1 = data.sheet_by_index(0)
# vlanNrows = vlanSheet1.nrows
# faiss = llm.store
# for r in range(1, vlanNrows):
#     question = vlanSheet1.cell(r, 0).value
#     answer = vlanSheet1.cell(r, 1).value
#     category = vlanSheet1.cell(r, 2).value
#     template = f"""分类 : {category} ; 问题：{question} ; 答案：{answer} """
#     print(template)
#     faiss.write_templates(template)

# # 打开文件
# data = xlrd.open_workbook(r'C:\Users\Yang.Shen9\Documents\ITSM派单地区及注意事项个人使用.xlsx')
#
# vlanSheet1 = data.sheet_by_index(1)
# vlanNrows = vlanSheet1.nrows
# faiss = llm.store
# for r in range(2, vlanNrows):
#
#     f_category = vlanSheet1.cell(r, 0).value
#     category = vlanSheet1.cell(r, 1).value
#     order_info = vlanSheet1.cell(r, 2).value
#     order_team = vlanSheet1.cell(r, 3).value
#     matters_needing_attention = """注意事项：
#        1.任何问题都需要在工单中详细描述具体问题
#        2.任何工单需要记录用户名字，邮箱，手机号再升级工单
#        3.桌面问题请将用户的办公地点备注在工单上
#        """
#     cucstom_matters_needing_attention = vlanSheet1.cell(r, 4).value
#     if cucstom_matters_needing_attention != "":
#         matters_needing_attention = matters_needing_attention + (""
#                                                                  "4.") + cucstom_matters_needing_attention
#     template = f"""分类 :{f_category}/{category} ; 工单中需要收集的信息：{order_info} ; 派单团队：{order_team} ;
#     {matters_needing_attention}"""
#     print(template)
#     faiss.write_templates(template)


# 打开文件
# data = xlrd.open_workbook(r'C:\Users\Yang.Shen9\Documents\ITSM派单地区及注意事项个人使用.xlsx')
#
# vlanSheet1 = data.sheet_by_index(0)
# vlanNrows = vlanSheet1.nrows
# faiss = llm.store
# for r in range(2, vlanNrows):
#
#     region = vlanSheet1.cell(r, 0).value
#     companies = vlanSheet1.cell(r, 1).value
#     event_location = vlanSheet1.cell(r, 2).value
#     order_team = vlanSheet1.cell(r, 3).value
#     cucstom_matters_needing_attention = vlanSheet1.cell(r, 4).value
#     if cucstom_matters_needing_attention != "":
#         cucstom_matters_needing_attention = """填写具体办公位置：""" + cucstom_matters_needing_attention
#     template = f"""区域 :{region}; 公司/基地/工厂: {companies} ; 对应事件发生地：{event_location} ; 对应IT团队：{order_team} ;
#         {cucstom_matters_needing_attention}"""
#     print(template)
#     faiss.write_templates(template)
